package com.inspur.system.utils;

import com.inspur.system.domain.vo.SysUserSaveProjVo;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class UserUtils
{
    public static List<SysUserSaveProjVo> updatePmNo (Long userId, String cPrdPer, String cPmNo, String cHeadPer) {
        List<SysUserSaveProjVo> users = new ArrayList<>();
        String[] cPrdPers = cPrdPer.split(",");
        String[] cHeadPers = cHeadPer.split(",");
        SysUserSaveProjVo user = new SysUserSaveProjVo(); // 我创建的
        user.setUserId((userId));
        user.setcCrePer(userId+"");
        user.setcPmNo(cPmNo);
        users.add(user);
        for (String cPerPer1 : cPrdPers) { // 我参与的
            SysUserSaveProjVo user1 = new SysUserSaveProjVo();
            user1.setUserId(Long.parseLong(cPerPer1));
            user1.setcPmNo(cPmNo);
            user1.setcPrdPer(cPerPer1);
            users.add(user1);
        }
        for (String cHeadPer1 : cHeadPers) { // 我负责的
            SysUserSaveProjVo user1 = new SysUserSaveProjVo();
            user1.setUserId(Long.parseLong(cHeadPer1));
            user1.setcPmNo(cPmNo);
            user1.setcHeadPer(cHeadPer1);
            users.add(user1);
        }
        return users;
    }

    public static Long queryUserNum (String cPmPer) {
        String[] cPrdPers = cPmPer.split(",");
        return (long)cPrdPers.length;
    }
}
